﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.DynamicData;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using NotAClue.Web;

namespace DD_Extensions
{
    public partial class Main : System.Web.UI.MasterPage
    {
        public String PageTitle { get; set; }

        public Menu Menu
        {
            get { return NavigationMenu; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void NavigationMenu_DataBound(object sender, EventArgs e)
        {
            if (NavigationMenu.SelectedItem != null)
            {
                PageTitle = NavigationMenu.SelectedItem.Text;

                // display TEST water mark on debug site
                var beta = Convert.ToBoolean(ConfigurationManager.AppSettings["TEST"]);
                if (beta)
                {
                    // add water mark style to page head
                    Page.AddCssToHead("~/Styles/Beta.css");
                    // add [TEST] to the page title
                    Page.Title = String.Format("{0} [TEST]", PageTitle);
                }
                else
                    Page.Title = PageTitle;
            }
        }

        protected void NavigationMenu_PreRender(object sender, EventArgs e)
        {
            //var user = Page.User.GetUserDetails();
            //if (user != null)
            //{
            //    //NavigationMenu.Items[2].NavigateUrl += String.Format("?PersonID={0}", user.PersonID);
            //    NavigationMenu.GetNode("My Provisions").NavigateUrl += String.Format("?PersonID={0}", user.PersonID);
            //}
            //else
            //    NavigationMenu.Items.Remove(NavigationMenu.GetNode("My Provisions"));
        }
    }
}